package com.wky1.wang1.service;

import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.wky1.wang1.mapper.DengluMapper;
import com.wky1.wang1.mapper.StudentMapper;
import com.wky1.wang1.pojo.Denglu;
import com.wky1.wang1.pojo.Pagebean;
import com.wky1.wang1.pojo.Student;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.time.LocalDateTime;
import java.util.List;

@Component
public class StudentServiceshixian implements StudentService {
    @Autowired
    private StudentMapper studentMapper;
    @Autowired
    private DengluMapper dengluMapper;





//查询
    @Override
    public List<Student> list() {

        return studentMapper.selectlist();
    }
//新增
    @Override
    public void set(Student student) {
        student.setUpdateTime(LocalDateTime.now());
        student.setSetTime(LocalDateTime.now());
        studentMapper.set(student);
    }
//修改
    @Override
    public void update(Student student) {
        student.setUpdateTime(LocalDateTime.now());
        studentMapper.update(student);
    }

    @Override
    public void delete(List<Integer> ids) {
   studentMapper.delete(ids);
    }

    @Override
    public Pagebean selectall(Integer page, Integer pageSize,String name,String num,Integer age) {
        //设置分页参数
        PageHelper.startPage(page,pageSize);
        //查询
        List<Student> studentlist=studentMapper.sleectall(name,num,age);
        Page<Student> p=(Page<Student>) studentlist;
        //封装Pagebean对象
        Pagebean pagebean=new Pagebean(p.getTotal(),p.getResult());
        return pagebean;
    }


}
